package org.apache.ibatis.test_clxmm.test02.proxy;

import org.apache.ibatis.test_clxmm.test02.proxy.service.UserService;
import org.apache.ibatis.test_clxmm.test02.proxy.service.handle.UserInvocationHandler;
import org.apache.ibatis.test_clxmm.test02.proxy.service.impl.UserServiceImpl;

import java.lang.reflect.Proxy;

public class Main {


  public static void main(String[] args) {
    // 创建目标对象
    UserServiceImpl userService = new UserServiceImpl();
    // 创建调用处理器
    UserInvocationHandler handler = new UserInvocationHandler(userService);
    // 创建代理对象
    UserService proxy = (UserService) Proxy.newProxyInstance(UserServiceImpl.class.getClassLoader(),
      UserServiceImpl.class.getInterfaces(),
      handler);
    System.out.println(proxy.login("1"));
  }



}
